var filePaths = "";
layui.config({
  version: "3.0.0"
  ,base: 'js/modes/' //这里实际使用时，建议改成绝对路径
}).extend({

}).use(['flow','form','layer','upload','element'],function() {

	  	var element = layui.element;
	  	var upload = layui.upload;
  
  	//多图片上传
  upload.render({
      elem: '.uploadNewImg',
      url: path + '/api/common/v1/fileUpload',
      multiple: false,
      exts:"jpg|png|gif|bmp|jpeg",
      before: function(obj) {
      	$("#layui-progress-big").css("display","block");
      	var progressNum = 19;
      	interval = setInterval(function() {
      		progressNum += 10;
      		if(progressNum <100) {
      			element.progress('uploadProgress', progressNum+'%');
      		}
           }, 1000);
      	 
      },choose: function(obj) {
          //将每次选择的文件追加到文件队列
    	  obj.pushFile();
      },
      done: function(data) {
          //上传完毕
          clearInterval(interval);
          
      	if(data.code == 0 && data.data) {
      		
      		element.progress('uploadProgress', 100+'%');
    		setTimeout(function() {
    			$("#layui-progress-big").css("display","none");
    			element.progress('uploadProgress', 20+'%');
			}, 1500);
    		
    		var divImg = "<div style='width: 50%;height: 120px;float: left;'><img src='"+data.data+"' style='height: 100px;width: 120px;'/></div>";
    		$(".files").append(divImg);
    		
    		if(filePaths == null || filePaths == "") {
    			filePaths = data.data;
    		} else {
    			filePaths += "," + data.data;
    		}
      		
      	} else {
      		$("#layui-progress-big").css("display","none");
     			element.progress('uploadProgress', 20+'%');
      		swal(data.message);
      	}
      }
  });
	
});